/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.gui.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import ui.WindowManager;
import ui.gui.documents.AbstractDocument;

/**
 *
 * @author stephane
 */
public class SaveFileAction extends AbstractAction {
    private static final long serialVersionUID = 1L;

    public SaveFileAction(JFrame parent) {
        super("Save file", new javax.swing.ImageIcon(SaveFileAction.class.getResource("/resources/saveFile.png")));
        putValue(SHORT_DESCRIPTION, "Save file");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        AbstractDocument selectedDocument = WindowManager.getInstance().getSelectedDocument();
        if (selectedDocument != null) {
            try {
            	
            		selectedDocument.OnSave();
            		selectedDocument.setIsDirty(false);
            	
            } catch (Exception ex) {
                System.out.println(ex);
            }
        }
    }
}